Type Refinements for Compiler Correctness
نویسندگان
چکیده
Type refinements, introduced by Freeman and Pfenning and explored by Davies and Dunfield, unify the ontological and epistemic views of typing. Types tell us what programming language constructs exist, whereas refinements express properties of the values of a type. Here we show that refinements are very useful in compiler correctness proofs, wherein it often arises that two expressions that are inequivalent in general are equivalent in the particular context in which they occur. Refinements serve to restrict the contexts sufficiently so that the desired equivalence holds. For example, an expression might be replaced by a more efficient one, even though it is not generally equivalent to the original, but is interchangeable in any context satisfying a specified refinement of the type of those expressions. We study here in detail a particular problem of compiler correctness, namely the correctness of compiling polymorphism (generics) to dynamic types by treating values of variable type as values of a universal dynamic type. Although this technique is widely used (for example, to compile Java generics), no proof of its correctness has been given to date. Surprisingly, standard arguments based on logical relations do not suffice, precisely because it is necessary to record deeper invariants about the compiled code than is expressible in their types alone. We show that refinements provide an elegant solution to this problem by capturing the required invariants so that a critical invertibility property that is false is general can be proved to hold in the contexts that arise in the translated code. This proof not only establishes the correctness of this compilation method, but also exemplifies the importance of refinements for compiler correctness proofs more generally.
منابع مشابه
Gerhard Schellhorn and Wolfgang Ahrendt the Wam Case Study: Verifying Compiler Correctness for Prolog with Kiv
This chapter describes the first half of the formal, machine-supported verification of a Prolog compiler with the KIV system. Our work is based on the mathematical analysis given in (Börger and Rosenzweig, 1995), where an operational semantics (an “interpreter”) for Prolog is defined as an Abstract State Machine (ASM). This interpreter is then transformed in 12 systematic refinements to an ASM ...
متن کاملA Higher-Order Logic for Concurrent Termination-Preserving Refinement
Compiler correctness proofs for higher-order concurrent languages are difficult: they involve establishing a termination-preserving refinement between a concurrent high-level source language and an implementation that uses low-level shared memory primitives. However, existing logics for proving concurrent refinement either neglect properties such as termination, or only handle first-order state...
متن کاملTechniques for Verifying Prolog Implementations
This paper presents some techniques that reduce the complexity of the verification of Prolog implementations. Two key techniques are stepwise refinements and bisimulation. The method of stepwise refinements captures various optimization techniques employed in the implementation process. The correctness of each refinement is justified using a notion called bisimulation. Our definition of bisimul...
متن کاملA Simplified Method for Establishing the Correctness of Architectural Refinements
My colleagues and I developed an approach to proving correctness of architectural reenement hierarchies that depended upon treating architectural speciications as axiomatizations of rst-order theories. This paper explores the consequences of an alternative approach to formalizing the content of speciications in logic. A speciication is treated as a depiction of a particular relational structure...
متن کاملProving Correctness of Compilers Using Structured Graphs
We present an approach to compiler implementation using Oliveira and Cook’s structured graphs that avoids the use of explicit jumps in the generated code. The advantage of our method is that it takes the implementation of a compiler using a tree type along with its correctness proof and turns it into a compiler implementation using a graph type along with a correctness proof. The implementation...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2013